<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<jsp:include page="../links.jsp"></jsp:include>
</head>
<body>
	<script type="text/javascript">
		var admin_user_datagrid;
		var admin_user_searchForm;
		var regDlgAdd;
		var regFormAdd;
		$(function() {
			admin_user_datagrid = $('#admin_user_datagrid').datagrid({
				url : getRootPath()+'/userAction/datagrid.do',
				title : '',
				iconCls : 'icon-save',
				pagination : true,
				pageSize : 10,
				pageList : [ 10, 20, 30, 40, 50 ],
				fit : true,
				fitColumns : true,
				nowarp : false,
				border : false,
				idField : 'id',
				sortName : 'id',
				sortOrder : 'asc',
				columns : [ [ {
					title : 'ID',
					field : 'id',
					width : 50,
					sortable : true
				}, {
					title : '编号',
					field : 'uid',
					width : 100,
					sortable : true
				}, {
					title : '用户名',
					field : 'name',
					width : 100,
					sortable : true
				}, {
					title : '用户类型',
					field : 'type',
					width : 100,
					sortable : true
				}, {
					title : '创建时间',
					field : 'createdatetime',
					width : 150
				}, {
					title : '最后修改时间',
					field : 'modifydatetime',
					width : 150
				} ] ],
				toolbar : [ {
					text : '新增',
					iconCls : 'icon-add',
					handler : function() {
						$('#regDlgAdd').dialog('open');
					}
				}
				/*
				'-', {
					text : '删除',
					iconCls : 'icon-remove',
					handler : function() {
					}
				}, '-', {
					text : '修改',
					iconCls : 'icon-edit',
					handler : function() {
						//admin_usermodify_dlg在top.jsp
						$('#admin_usermodify_dlg').dialog('open');
					}
				} 
				*/
				]
			});//datagrid end
			//过滤查询
			admin_user_searchForm = $('#admin_user_searchForm').form();
			doSearch = function() {
				//console.info('11');
				console.info(serializeObject(admin_user_searchForm));
				admin_user_datagrid.datagrid('load', serializeObject(admin_user_searchForm));
			};
			//重置
			cleanSearch = function() {
				admin_user_datagrid.datagrid('load', {});
				admin_user_searchForm.find('input').val('');
			};
			//添加
			regDlgAdd = $('#regDlgAdd').dialog({
				title : '新增用户',
				closed : true,
				cache : false,
				iconCls : 'icon-tip',
				modal : true,
				buttons : [ {
					text : '添加',
					handler : function() {
						$('#regFormAdd').submit();
					}
				}, {
					text : '关闭',
					handler : function() {
						$('#regDlgAdd').dialog('close');
					}
				} ]
			});
			regFormAdd = $('#regFormAdd').form({
				url : 'userAction/reg.do',
				onSubmit : function() {
					if ($('#pwd1').val() == $('#pwd2').val()) {
						return true;
					} else {
						$.messager.alert('提示', '两次密码输入不一致');
						$("input[name='pwd']").val('');
						$("input[name='repwd']").val('');
						return false;
					}
				},
				success : function(r) {
					r = $.parseJSON(r);//将标准json转成obj
					if (r && r.success) {
						$('#regDlgAdd').dialog('close');
						$.messager.show({
							title : '提示',
							msg : '添加成功',
							showType : 'show'
						});
					}
				}
			});
		});
	</script>
	<div id="regDlgAdd" style="width: 330px; height: 270px; padding: 22px">
		<form id="regFormAdd" method="post">
			<table cellpadding="5">
				<tr>
					<th>用户名</th>
					<td><input class="easyui-validatebox" type="text" name="name"
						data-options="novalidate:true,missingMessage:'请输入用户名'"></input></td>
				</tr>
				<tr>
					<th>密码</th>
					<td><input id="pwd1" class="easyui-validatebox" name="pwd" type="password"
						data-options="novalidate:true,missingMessage:'请输入密码'" /></td>
				</tr>
				<tr>
					<th>确认密码</th>
					<td><input id="pwd2" class="easyui-validatebox" name="repwd" type="password"
						data-options="novalidate:true,missingMessage:'重复输入密码'" /></td>
				</tr>
				<tr>
					<th>用户类型</th>
					<td><select class="easyui-combobox" name="type" style="width: 100%" panelHeight="42px">
							<option value="admin">管理员</option>
							<option value="user">普通用户</option>
					</select></td>
				</tr>
			</table>
		</form>
	</div>
	<div class="easyui-layout" fit="true" border="false">
		<div data-options="region:'north',title:'模糊查询条件：'" style="height: 100%;">
			<form id="admin_user_searchForm" method="post">
				<table clase="tableForm" style="width: 100%; height: 60%;">
					<tr>
						<th>ID</th>
						<td><input name="id" /></td>
						<th>编号</th>
						<td><input name="uid" /></td>
						<th>创建时间</th>
						<td><input name="createdatetimeStart" class="easyui-datetimebox" editable="false" />至<input
							name="createdatetimeEnd" class="easyui-datetimebox" editable="false" /></td>
					</tr>
					<tr>
						<th>用户名</th>
						<td><input name="name" /></td>
						<th>用户类型</th>
						<td><input name="type" /></td>
						<th>最后修改时间</th>
						<td><input name="modifydatetimeStart" class="easyui-datetimebox" editable="false" />至<input
							name="modifydatetimeEnd" class="easyui-datetimebox" editable="false" /> <a class="easyui-linkbutton"
							data-options="iconCls:'icon-search'" href="javascript:void(0)" onclick="doSearch();">查询</a> <a
							class="easyui-linkbutton" data-options="iconCls:'icon-redo'" href="javascript:void(0)" onclick="cleanSearch();">清空</a></td>
					</tr>
				</table>
			</form>
		</div>
		<div data-options="region:'center',title:''," style="overflow: hidden;">
			<table id="admin_user_datagrid">
			</table>
		</div>
	</div>
</body>
</html>